package com.jp.vn.main;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;

public class PopupMenu extends BetterPopupWindow {

	ViewGroup root;
	LinearLayout timKiem, hiragana, katakana, phatAm, giaoTiep, soDem,
			thoiGian, bo, chu, tuVung, nguPhap, luyenTap;
	HorizontalScrollView scrollView;

	public PopupMenu(View anchor, int height, int width) {
		super(anchor, height, width);
	}

	protected void onCreate() {
		LayoutInflater inflater = (LayoutInflater) this.anchor.getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		root = (ViewGroup) inflater.inflate(R.layout.menu_popup, null);
		scrollView = (HorizontalScrollView) root.findViewById(R.id.menu_popup);

		timKiem = (LinearLayout) root.findViewById(R.id.layout_timkiem);
		hiragana = (LinearLayout) root.findViewById(R.id.layout_hiragana);
		katakana = (LinearLayout) root.findViewById(R.id.layout_katakana);
		phatAm = (LinearLayout) root.findViewById(R.id.layout_phatam);
		giaoTiep = (LinearLayout) root.findViewById(R.id.layout_giaotiep);
		soDem = (LinearLayout) root.findViewById(R.id.layout_sodem);

		timKiem.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				dismiss();
				Intent intent = new Intent(anchor.getContext(),
						TimKiemActivity.class);
				anchor.getContext().startActivity(intent);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		hiragana.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				dismiss();
				Intent hiragana = new Intent(anchor.getContext(),
						HiraganaActivity.class);
				anchor.getContext().startActivity(hiragana);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		katakana.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
				Intent intent = new Intent(anchor.getContext(),
						KatakanaActivity.class);
				anchor.getContext().startActivity(intent);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		phatAm.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
				Intent intent = new Intent(anchor.getContext(),
						PhatAmActivity.class);
				anchor.getContext().startActivity(intent);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		giaoTiep.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
				Intent intent = new Intent(anchor.getContext(),
						GreetingActivity.class);
				anchor.getContext().startActivity(intent);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		soDem.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				dismiss();
				Intent intent = new Intent(anchor.getContext(),
						SoDemActivity.class);
				anchor.getContext().startActivity(intent);
				((Activity) anchor.getContext()).overridePendingTransition(
						R.anim.right_in, R.anim.left_out);
			}
		});

		this.setContentView(root, height, width);
	}
}
